home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / mlib / doc / mlib.doc < prev   
Encoding:
Text File  |  1994-04-16  |  14.7 KB  |  378 lines

  1. ===============================================================================
  2. ░░░░░░░░░░░░░░░▒▒▒▒▒▓▓▓▓ MLIB scarce documentaion ▓▓▓▓▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░
  3. ===============================================================================
  4.  
  5. Note: This document looks great in a colorized Borland IDE.
  6.  
  7. ===============================================================================
  8. 1. What is it?
  9.  
  10.     MLIB is intended to be a library for game development. It was supposed
  11. to be similar to YakIcons. It came close, but not enough. It is more abstract
  12. and unfortunately less optimized.
  13.  
  14. ===============================================================================
  15. 2. What does it have?
  16.  
  17.     MLIB has a simple graphics library for the plain VGA mode 0x13. The
  18. library is written in C++ and some very rare instances of inline assembler
  19. (I guess that shows that I am not very good at assembler... So if you want
  20. to draw high-speed primitives, someone will have to do the dirty work. I
  21. simply assumed that games are written with bitmaps and it is the fastest
  22. thing I made)
  23.     The rest of the library is written almost completely in C++ and
  24. has the following classes:
  25.  
  26. -------------------------------------------------------------------------------
  27. Note1: one thing, do not delete a pointer that you have just inserted in a
  28.     data storage class like a LList or a HashTable, and do not do that
  29.     with local variables. They would be deleted by the destructor.
  30.     This comment applies to all data storage classes.
  31.  
  32. Note2: length always denotes the horizontal dimention,
  33.        width always denotes the vertical dimention.
  34.  
  35. Note3: {} - a member function
  36.        <> - an external function
  37.  
  38. Note4: Classes are in alphabetical order.
  39. -------------------------------------------------------------------------------
  40.  
  41. # AniMob     : public MMob
  42.  
  43.     AniMob is a MOB (see MMob) with many AnimLoops that can be cycled
  44. through. Each AniMob can have any number of AnimLoops. AnimLoops are
  45. maintained in a linked list.
  46.  
  47. # AnimLoop   : public MObject, public MFileOp
  48.  
  49.     AnimLoop is a linked list of MImages. AnimLoop is designed to
  50. implement many actions that an object in a game can do. Each AnimLoop may
  51. represent one action. I think it is easier to understand than a mess of
  52. images in one place.
  53.  
  54. # Atom       : public MObject, public MFileOp
  55.  
  56.     This is the base data class; it can hold allocated memory. The memory
  57. is accessed through the pointer {void* mem}. The allocated block is assumed
  58. to be broken into several subblocks or elements of equal size. Size of each
  59. element is in {elSize}, number of elements is in {nElem}, and the overall
  60. size of the allocated block is in {size}. Member functions perform all the
  61. needed memory operations. The block can be any size under 64K (the limit of
  62. malloc). This restriction also applies to any classes derived from it.
  63.  
  64. # Complex    : public MObject
  65.  
  66.     A simple complex number class. I know I used it for something...
  67.  
  68. # DC         : public MObject
  69.  
  70.     DC is similar to MS Windows device context. It has information about
  71. the output address and dimentions, colors, and some other things.
  72.  
  73. # Display    : virtual public MObject
  74.  
  75.     This class describes a place in memory where graphics output is
  76. being redirected. It has {address}, {length}, and {width}. Usual settings
  77. are 0xA000, 320, 200 to draw directly to VGA memory.
  78.  
  79. # HashEntry
  80.  
  81.     All classes derived from this one can be stored in a HashTable. The
  82. class requires from you a hash key definition routine and the {==} operator.
  83.  
  84. # HashTable  : public Atom
  85.  
  86.     A hash table. Use it in whatever way you like.
  87.  
  88. # IntPoint
  89.  
  90.     A class that defines integer coordinates for a point. {=}.
  91.  
  92. # LCList     : public LList
  93.  
  94.     Circular doubly linked list. Implemented primarily as a base for
  95. AnimLoop, but can have other uses.
  96.  
  97. # LLElem
  98.  
  99.     This is an internal class, which is used as a 'cart' for LList's
  100. entries.
  101.  
  102. # LList      : public MObject
  103.  
  104.     Doubly linked list. Inserted objects do not contain {next} and
  105. {prev}. They are pointed to by the 'cart'. Any kind of element can be
  106. inserted. A 'cart' would be created for it:
  107.     ┌────┐                                          ┌───┐
  108.     └────┘  -> through InsertAfter ->  ══ ══  ->    └─╥─┘
  109.                          │        ════╩════
  110.                          └ Current
  111.  
  112. # MAplane    : public cArray
  113.  
  114.     An offscreen page in memory. {Put},{Get}. Redirect to it using
  115. <setdpy> and draw. This class could benefit somewhat from an assembler 32 bit
  116. copy routine, but I did want to make the library to be compatible with 286's.
  117.  
  118. # MButton    : public MLabel
  119.  
  120.     A window class. Executes {UserHandler} if clicked upon with mouse.
  121.  
  122. # MCMap      : public MStGrid
  123.  
  124.     A window class. Sets draw color on left click, fill color on right.
  125. Displays 256 colors in a box. Based on MStGrid.
  126.  
  127. # MCheck     : public MButton
  128.  
  129.     A window class. Standart checkbox. Calls {UserHandler} on click.
  130.  
  131. # MEvent : public MObject
  132.  
  133.     This is the event class. Events include key presses, mouse moves, and
  134. mouse clicks. Obtained by <GetEvent> and created by <CreateEvent>.
  135.  
  136. # MFileOp
  137.  
  138.     All files derived from this class have {Load} and {Save}. This class
  139. basically has routines that close and open files and pass the descriptor to
  140. the derived class.
  141.  
  142. # MFont      : public Atom
  143.  
  144.     A bitmapped font. Draws letters by pixels, which is slow, but it keeps
  145. the code looking nice and readable.
  146.  
  147. # MGraph     : public MObject
  148.  
  149.     Graphics control structure. Unconditionally defines {font} and
  150. {palette}. Has a pointer to an Aplane, which can be created by you. Font
  151. is loaded from "default.fnt" file in current directory. If the file is not
  152. found, no text will be visible. You can load your own font too.
  153.  
  154. # MImage     : public cArray
  155.  
  156.     A screen image. Stores a block of pixels. {Put},{Get},{Load},{Save}.
  157. Note: It is RLE compressed when saved to file.
  158.  
  159. # MKey       : public bArray
  160.  
  161.     A keyboard extention. {GetKey},{KeyPress},{KeyFlush}, or access {keys}
  162. directly ({keys} is a bArray, which is the idea taken from YakIcons).
  163.  
  164. # MLabel     : public MWindow
  165.  
  166.     A window with a label.
  167.  
  168. # MMob       : public MObject, public MFileOp
  169.  
  170.     The Moving OBject class. MOB is an image with a background, that can
  171. be moved on screen using double-buffering. Mouse is a typical MOB. Use
  172. {MoveTo} to move and {RescanBackgr} if you draw over it. You can also {Hide}
  173. and {Show} it.
  174.  
  175. # MMouse     : public MMob
  176.  
  177.     A mouse class. It is usually defined globally and unconditionally if
  178. you link to MWIN.LIB. I assume that you do not need to create any more mouse
  179. handlers. Use the default class named <mouse> or if you    want more handlers,
  180. go ahead!
  181.  
  182. # MObject
  183.  
  184.     The base class for the whole hierarchy. It was created at first to
  185. use the Borland class library without having to redefine all the pure virtual
  186. functions. Now I have removed the link to the class library, but if you want
  187. to enable it, simply include <object.h> in the mobject.h file and the
  188. conditional compilation will do the rest. This class also defines new
  189. {new} and {delete}. If you do not want that, undefine USER_NEW_AND_DELETE.
  190.  
  191. # MPal       : public Atom
  192.  
  193.     Palette class. {FadeIn}, {FadeOut}, {SetAll}, {SetRGB}.
  194.  
  195. # MParent    : public MWindow
  196.  
  197.     A window that may have child windows attached. Children are maintained
  198. in a linked list and are managed automatically. Children create an event upon
  199. creation to attach themselves to their parent. Call parent's {Realize} to
  200. attach all the children. The call {Run} and it will go.
  201.  
  202. # MScGrid    : public MScroller
  203.  
  204.     A grid of cells that can be scrolled around. Define {Draw(int,int)} to
  205. draw one cell with given coordinates.
  206.  
  207. # MScroller  : public MWindow
  208.  
  209.     A simple class that maintains the coordinates of a window in a big
  210. world. That's it.
  211.  
  212. # MStGrid    : public MWindow
  213.  
  214.     A static grid of elements. Define {Draw(int,int)}.
  215.  
  216. # MTree      : public MObject
  217.  
  218.     This is a multi-leaf tree. Each node is basically a linked list
  219. element and a linked list in one.
  220.  
  221. # MWindow    : public MTree, public MFileOp
  222.  
  223.     The simplest window. Has size, coordinates, {UserHandler}.
  224.  
  225. # Queue      : public LList
  226.  
  227.     A queue.
  228.  
  229. # SimpleRect : virtual public MObject
  230.  
  231.     A rectangle with {left},{top},{right}, and {bottom}.
  232.  
  233. # Stack      : public LList
  234.  
  235.     A stack.
  236.  
  237. # ViewPort   : public SimpleRect
  238.  
  239.     SimpleRect with added {length} and {width}.
  240.  
  241. # bArray     : public Atom
  242.  
  243.     Bit array. Access bits with [], which returns BOOL.
  244.  
  245. # cArray     : public Atom
  246.  
  247.     Char array.
  248.  
  249. # multifile  : public MObject
  250.  
  251.     Utility for big data files. To read a file from a multifile use
  252. {GetOffset (filename)} to get its offset in the big file and read it. See
  253. the utility mulleman.exe provided to make multifiles.
  254.  
  255. # wArray     : public Atom
  256.  
  257.     Array of WORD values.
  258.  
  259. -------------------------------------------------------------------------------
  260.  
  261.     If the above reference is not enough, tell me what exactly do you want.
  262. I am too familiar with the code to be a good judge of what needs to be in the
  263. documentation, so I wrote what I thought was essential.
  264.  
  265. ===============================================================================
  266. 4. How come the demo is so bad?
  267.  
  268.     I can't draw. If you do not believe me, look at pos0.pix. And I hate
  269. writing specific code. That's probably why I write libraries, not games.
  270.  
  271. ===============================================================================
  272. 5. What do you need to run it:
  273.  
  274.     A 80286 processor is preferred, but it may also work under 8086, even
  275. though I have not tried it because I do not have it. The graphics portion
  276. needs a VGA screen and card. There may be an incompatibility with some
  277. very old versions of DOS. Tell me if you find something.
  278.     Current libraries are compiled for an 386. If you have a slower
  279. machine, recompile them. There is a big chance that they will work.
  280.  
  281. ===============================================================================
  282. 6. How to compile a program using it
  283.  
  284.     1. Include <mio.h>
  285.     2. If you are using graphics, include <mgr.h>
  286.     3. If you are using the window system, include <mwindow.h>,
  287.         <mparent.h>, and include files for controls if you have
  288.         used any (all of them can be included with <mcontrol.h>)
  289.     4. Link with appropriate libraries:
  290.         MMEM.LIB   - Always needed
  291.         MIO.LIB    - Include for MKey and MMulle
  292.         MTYPES.LIB - Always needed
  293.         MGRAPH.LIB - Graphics library
  294.         MWIN.LIB   - Window basics (MWindow, MParent, MEvent, MMouse)
  295.         MCONTROL.LIB - Additional windows
  296.  
  297.     You can recompile the libraries if they do not work with your compiler.
  298. I have included Borland C++ project and a makefile for each one.
  299.  
  300. ===============================================================================
  301. 7. How to use the mouse
  302.  
  303.     The mouse is automatically installed if you link with MWIN.LIB because
  304. it is assumed that you need mouse for windows, even though a mouse can be used
  305. without windows. A global class <mouse> is defined, which can be called.
  306.  
  307. ===============================================================================
  308. 8. How to use the graphics
  309.  
  310.     The syntax is almost similar to BGI graphics. Initialize with
  311. <initgraph> with no parameters. This will put you in mode VGA 0x13. To
  312. restore text mode call closegraph. Look in "mgraph.h" for available
  313. functions.
  314.     The graphics control structure is global and is called <gr>. It has
  315. information about current display, i.e. its dimentions, current colors, its
  316. address. You can draw the primitives or images into any area of memory. Simply
  317. use the <setdpy> call to set the address and dimentions of the new screen.
  318.     There are useful functions <push_DC> and <pop_DC> which save current
  319. control structure on stack, so that you do not have to save it yourself.
  320.  
  321. ===============================================================================
  322. 9. How to use the windows
  323.  
  324.     The window system is automatically initialized when you link with
  325. MWIN.LIB but it is not active. Any window you create will attach itself to a
  326. predefined root window called <root>, which is a global structure. This is
  327. an event-based system, so it is programmed accordingly. When you have created
  328. all your windows, call <root.Realize> function to process all the addition
  329. events at once. Then call <root.Run> and the system will do the rest.
  330.     The above instructions also apply to any parent window that you create.
  331. Simply replace <root> with your window.
  332.     Windows require a mouse. If you do not have a mouse, get an emulator.
  333. One is distributed by Microsoft and can be obtained by ftp from
  334. ftp.microsoft.com in a package called DOS6SUPP.EXE. Or even better, buy
  335. a mouse! It is one piece of hardware that you WANT to have.
  336.     One more thing, the window system is rather unstable. I have had some
  337. random reboots for no apparent reason with complex systems like the DRAW
  338. editor. No, there is never any damage to the system. The cause of the 
  339. unstablity is uncertain.
  340.  
  341. ===============================================================================
  342. 10. How to use a Mulle
  343.  
  344.     A Mulle or a multifile is a collection of files in one. To create a
  345. multifile create a listing of all the files you want to combine. The listing
  346. file should contain the number of files that you wish to combine. Then use the
  347. utility MULLEMAN provided in this package (hopefully).
  348.  
  349. ===============================================================================
  350. 11. Ok, is it mine?
  351.  
  352.     This library is free. You can have it. If you cannot afford shareware
  353. because you are a poor college student like myself you will understand what I
  354. mean. Also, this library is not THAT good to be worth much, it is slow and it
  355. is in C++. Besides, there are much better libraries that are free, like XLib.
  356. YakIcons is not free but as I heard, its creator has only earned $23.
  357.     So, you can use MLIB anytime for as long as you want. Only if you
  358. write something public, include something like <Using MLIB by Mike Sharov>
  359. somewhere. This is not much to ask, is it?
  360.  
  361. ===============================================================================
  362. 12. What to do with bugs?
  363.  
  364.     This library has bugs. I admit it. There is one visible in DRAW,
  365. where you cannot load an image sometimes (totally random behavior). You can
  366. save it though. That is a bug somewhere in the windowing system. I did not
  367. want to give you a defective program, its just that the rest of the library
  368. works fine and I have almost gave up on that bug, since I have been trying
  369. to locate it for a very long time. Anyway, if you find any more bugs, or if
  370. you find where this one is, tell me. My e-mail address is
  371.  
  372. -------------------------------------------------------------------------------
  373.     msharov@triton.sunlab.cs.runet.edu
  374. -------------------------------------------------------------------------------
  375.  
  376. I would really appreciate that.
  377.  
  378. ===============================================================================